<?php
// no direct access

defined( '_JEXEC' ) or die( 'Restricted access' );
require(JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.shop.php');
$user = JFactory::getUser();
$oConf = ShopController::conf();
$db = JFactory::getDBO();
$db->setQuery("SELECT cb_discount FROM #__comprofiler WHERE user_id=".$user->id);
$discount = $db->loadRow();
$discount = $discount[0];
?>
<h1>
Ваши заказы
</h1>
<?php if($discount > 0):?>
Ваша скидка составляет <?php echo $discount?>% <br/><br/>
<?php endif;?>
<?php if(count($this->basket)>0): foreach($this->basket as $k=>$basket):?>
<table cellpadding=3 cellspacing=2 class="basket_list">
	<tr>
		<th>№</th>
		<th>Дата</th> 
		<th>Содержимое заказа</th>
		<th>Сумма заказа</th>
		<?php if($basket->discount_sum != 0 ||  ($basket->discount_sum != $basket->sum && $basket->discount_sum>0)):?><th>	Сумма заказа <br/>с учетом скидки: </th><?php endif;?>
		<th>Состояние заказа</th>
	</tr>
	
	<tr>
		<td><?php echo $basket->id;?></td>
		<td><?php echo $basket->date;?></td>
		<td>
		<?php $i=1;foreach($this->goods[$k] as $goods):?>
		<?php echo $i;?>)<a href="index.php?option=com_shop&view=item&id=<?php echo $goods[articul];?>"><?php echo htmlspecialchars($goods[name])?></a> - <?php echo  htmlspecialchars($goods[type]).' - '.$goods[quantity];?> шт.<br/>
		<?php $i++; endforeach;?>
		</td>
		<td align="center"><?php echo $this->sum[$k]; ?>руб.</td>
		<?php if($basket->discount_sum != 0 ||  ($basket->discount_sum != $basket->sum && $basket->discount_sum>0)):?>	<td  align="right" style="border:0;"><b><?php echo $basket->discount_sum; ?>руб</b>.	</td><?php endif;?>
		<td align="center"><?php echo $basket->status;?></td>
	</tr>	
</table>
<p class="manager_comment">
<?php if($basket->manager_comment != '') echo "<b>Комментарий менеджера: </b>$basket->manager_comment";?>
</p>

<?php endforeach;?>
<?php endif?>
<?php if(count($this->done_basket)>0): echo '<h3>Выполненные заказы</h3>'; ?>
<?php foreach($this->done_basket as $k=>$basket):?>
<table cellpadding=3 cellspacing=2 class="basket_list">
	<tr>
		<th>№</th>
		<th>Дата</th> 
		<th>Содержимое заказа</th>
		<th>Сумма заказа</th>
		<?php if($basket->discount_sum != 0 ||  ($basket->discount_sum != $basket->sum && $basket->discount_sum>0)):?><th>	Сумма заказа <br/>с учетом скидки: </th><?php endif;?>
		<th>Состояние заказа</th>
	</tr>
	
	<tr>
		<td><?php echo $basket->id;?></td>
		<td><?php echo $basket->date;?></td>
		<td>
		<?php $i=1;foreach($this->done_goods[$k] as $goods):?>
		<?php echo $i;?>)<a href="index.php?option=com_shop&view=item&id=<?php echo $goods[articul];?>"><?php echo htmlspecialchars($goods[name])?></a> - <?php echo  htmlspecialchars($goods[type]).' - '.$goods[quantity];?> шт.<br/>
		<?php $i++; endforeach;?>
		</td>
		<td align="center"><?php echo $basket->sum; ?>руб.</td>
		<?php if($basket->discount_sum != 0 ||  ($basket->discount_sum != $basket->sum && $basket->discount_sum>0)):?>	<td  align="right" style="border:0;"><b><?php echo (int)$basket->discount_sum; ?>руб</b>.	</td><?php endif;?>
		<td align="center"><?php echo $basket->status;?></td>
	</tr>	
</table>
<p class="manager_comment">
<?php if($basket->manager_comment != '') echo "<b>Комментарий менеджера: </b>$basket->manager_comment";?>
</p>

<?php endforeach;?>

<?php endif;?>
<?php if(count($this->basket)==0 && count($this->done_basket)==0 ) echo 'У вас нет заказов'; ?> 